import datetime

from django.db import models
from django.utils import timezone
from taggit.managers import TaggableManager
# Create your models here.
class Question(models.Model):
    """docstring for Question"""
    question_text = models.CharField(max_length=300)
    pub_date = models.DateTimeField("date published")
    shenfenzhenghao = models.CharField(max_length=18, null=True, blank=True)
    tags = TaggableManager()
    def __str__(self):
        return self.question_text

    def was_published_recently(self):
        now = timezone.now()
        return now - datetime.timedelta(days=1) <= self.pub_date <= now
#        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
    was_published_recently.admin_order_field = 'pub_date'
    was_published_recently.boolean = True
    was_published_recently.short_description = 'Published recently?'

class Choice(models.Model):
    """docstring for Chioce"""
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=20)
    votes = models.IntegerField(default=0)
    xuhao = models.CharField(max_length=20)
    danweiquancehng =models.CharField(max_length=20)
    danweijiancheng = models.CharField(max_length=20)
    def __str__(self):
        return self.choice_text

class ClassName(object):
    """docstring for ClassName"""
    def __init__(self, arg):
        super(ClassName, self).__init__()
        self.arg = arg
        
